from sqlalchemy import Column, Integer, String, Text, Boolean, DateTime, Float, JSON
from sqlalchemy.sql import func
from backend.database.database import Base

class Brand(Base):
    """品牌管理表"""
    __tablename__ = "brands"

    id = Column(Integer, primary_key=True, index=True)
    name = Column(String(100), nullable=False, comment="品牌名称")
    logo_url = Column(String(255), nullable=True, comment="品牌logo")
    website = Column(String(255), nullable=True, comment="官网链接")
    description = Column(Text, nullable=True, comment="品牌描述")
    is_active = Column(Boolean, default=True, comment="是否激活")
    created_at = Column(DateTime, default=func.now(), comment="创建时间")
    updated_at = Column(DateTime, default=func.now(), onupdate=func.now(), comment="更新时间")

class ProductName(Base):
    """商品名称管理表"""
    __tablename__ = "product_names"

    id = Column(Integer, primary_key=True, index=True)
    name = Column(String(100), nullable=False, comment="商品名称")
    category = Column(String(50), nullable=True, comment="商品分类")
    description = Column(Text, nullable=True, comment="描述")
    is_active = Column(Boolean, default=True, comment="是否激活")
    created_at = Column(DateTime, default=func.now(), comment="创建时间")
    updated_at = Column(DateTime, default=func.now(), onupdate=func.now(), comment="更新时间")

class Unit(Base):
    """单位管理表"""
    __tablename__ = "units"

    id = Column(Integer, primary_key=True, index=True)
    name = Column(String(50), nullable=False, comment="单位名称")
    symbol = Column(String(20), nullable=False, comment="单位符号")
    type = Column(String(20), nullable=True, comment="单位类型：重量/长度/容量/数量/其他")
    description = Column(Text, nullable=True, comment="描述")
    is_active = Column(Boolean, default=True, comment="是否激活")
    created_at = Column(DateTime, default=func.now(), comment="创建时间")
    updated_at = Column(DateTime, default=func.now(), onupdate=func.now(), comment="更新时间")

class MarketingWord(Base):
    """营销词管理表"""
    __tablename__ = "marketing_words"

    id = Column(Integer, primary_key=True, index=True)
    content = Column(Text, nullable=False, comment="营销词内容")
    category = Column(String(50), nullable=True, comment="分类：价格/品质/促销/特性/其他")
    description = Column(Text, nullable=True, comment="描述")
    is_active = Column(Boolean, default=True, comment="是否激活")
    created_at = Column(DateTime, default=func.now(), comment="创建时间")
    updated_at = Column(DateTime, default=func.now(), onupdate=func.now(), comment="更新时间")

class SystemConfig(Base):
    """系统配置表"""
    __tablename__ = "system_configs"

    id = Column(Integer, primary_key=True, index=True)
    key = Column(String(50), nullable=False, unique=True, comment="配置键")
    value = Column(Text, nullable=False, comment="配置值")
    type = Column(String(20), nullable=False, comment="数据类型：string/number/boolean/json")
    description = Column(Text, nullable=True, comment="描述")
    created_at = Column(DateTime, default=func.now(), comment="创建时间")
    updated_at = Column(DateTime, default=func.now(), onupdate=func.now(), comment="更新时间") 